home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / mac / data / xxi_appendice_dvd.swf / scripts / __Packages / CAppendiceStyleManager.as < prev    next >
Text File  |  2007-11-08  |  15KB  |  207 lines

  1. class CAppendiceStyleManager extends AsBroadcaster
  2. {
  3.    static var USE_SUB_SUP_FONT = false;
  4.    static var USE_EMBEDDED_FONT = false;
  5.    function CAppendiceStyleManager(inBaseFont, inApiceFont, inPediceFont, inNormalSize, inSmallSize, inBigSize)
  6.    {
  7.       super();
  8.       this.mCurrentView = "normal";
  9.       this.mBaseFont = inBaseFont;
  10.       this.mApiceFont = inApiceFont;
  11.       this.mPediceFont = inPediceFont;
  12.       this.mNormalSize = inNormalSize;
  13.       this.mSmallSize = inSmallSize;
  14.       this.mBigSize = inBigSize;
  15.       this.mMargin = 16;
  16.       this.mPrintMargin = 28;
  17.       this.mMarginTitle = 0;
  18.       this.mPreviewMargin = 16;
  19.       this.mPreviewMarginTitle = 16;
  20.       this.mPreviewNormalSize = this.mNormalSize - 1;
  21.       this.mPreviewSmallSize = this.mSmallSize - 1;
  22.       this.mPreviewBigSize = this.mBigSize - 1;
  23.       this.mPrintSize = inNormalSize;
  24.       this.init();
  25.    }
  26.    function SetView(inView)
  27.    {
  28.       if(inView != this.mCurrentView)
  29.       {
  30.          this.mCurrentView = inView;
  31.          if(this.mCurrentView == "big")
  32.          {
  33.             this.initStyle(this.mCSS,this.mBigSize,this.mMargin,this.mMarginTitle);
  34.             this.initStyle(this.mPreviewCSS,this.mPreviewBigSize,this.mPreviewMargin,this.mPreviewMarginTitle);
  35.          }
  36.          else if(this.mCurrentView == "small")
  37.          {
  38.             this.initStyle(this.mCSS,this.mSmallSize,this.mMargin,this.mMarginTitle);
  39.             this.initStyle(this.mPreviewCSS,this.mPreviewSmallSize,this.mPreviewMargin,this.mPreviewMarginTitle);
  40.          }
  41.          else
  42.          {
  43.             this.initStyle(this.mCSS,this.mNormalSize,this.mMargin,this.mMarginTitle);
  44.             this.initStyle(this.mPreviewCSS,this.mPreviewNormalSize,this.mPreviewMargin,this.mPreviewMarginTitle);
  45.          }
  46.          this.broadcastMessage("onFontSizeChanged");
  47.       }
  48.    }
  49.    function init()
  50.    {
  51.       this.mCSS = new TextField.StyleSheet();
  52.       this.initStyle(this.mCSS,this.mNormalSize,this.mMargin,this.mMarginTitle);
  53.       this.mPrintCSS = new TextField.StyleSheet();
  54.       this.initStyle(this.mPrintCSS,this.mPrintSize,this.mPrintMargin,this.mPrintMargin);
  55.       this.mPreviewCSS = new TextField.StyleSheet();
  56.       this.initStyle(this.mPreviewCSS,this.mPreviewNormalSize,this.mPreviewMargin,this.mPreviewMarginTitle);
  57.       AsBroadcaster.initialize(this);
  58.       HtmlListboxCellRenderer.USE_EMBEDDED_FONT = CAppendiceStyleManager.USE_EMBEDDED_FONT;
  59.       HtmlTreeCellRenderer.USE_EMBEDDED_FONT = CAppendiceStyleManager.USE_EMBEDDED_FONT;
  60.       HtmlMenuCellRenderer.USE_EMBEDDED_FONT = CAppendiceStyleManager.USE_EMBEDDED_FONT;
  61.       HtmlListboxCellRenderer.style_sheet = this.GetCSS();
  62.       HtmlTreeCellRenderer.style_sheet = this.GetCSS();
  63.       HtmlMenuCellRenderer.style_sheet = this.GetCSS();
  64.       EmbedHtmlMenuCellRenderer.style_sheet = this.GetCSS();
  65.    }
  66.    function GetPreviewCSS()
  67.    {
  68.       return this.mPreviewCSS;
  69.    }
  70.    function GetPrintCSS()
  71.    {
  72.       return this.mPrintCSS;
  73.    }
  74.    function GetCSS()
  75.    {
  76.       return this.mCSS;
  77.    }
  78.    function initStyle(inStyle, inSize, inMargin, inMarginTitle)
  79.    {
  80.       if(CAppendiceStyleManager.USE_EMBEDDED_FONT)
  81.       {
  82.          this.initStyleEmbedded(inStyle,inSize,inMargin,inMarginTitle);
  83.       }
  84.       else
  85.       {
  86.          this.initStyleDeviceFont(inStyle,inSize,inMargin,inMarginTitle);
  87.       }
  88.    }
  89.    function initStyleDeviceFont(inStyle, inSize, inMargin, inMarginTitle)
  90.    {
  91.       inStyle.setStyle(".rowText",{fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"normal"});
  92.       inStyle.setStyle(".menuRowText",{fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"normal"});
  93.       inStyle.setStyle(".menuRowTextEmbed",{fontFamily:"ArialEmbed",fontSize:11.5,fontWeight:"normal",fontStyle:"normal",textAlign:"center"});
  94.       inStyle.setStyle(".menuProspettive",{fontFamily:"ArialEmbed",fontSize:12,fontWeight:"bold",fontStyle:"normal",textAlign:"left"});
  95.       inStyle.setStyle(".S_SCAPS",{fontSize:this.mNormalSize - 2});
  96.       inStyle.setStyle(".s_content",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"normal"});
  97.       inStyle.setStyle(".s_abstract",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"normal"});
  98.       inStyle.setStyle(".s_title0",{marginLeft:inMarginTitle,marginRight:inMarginTitle,fontFamily:this.mBaseFont,fontSize:inSize + 4,fontWeight:"bold",fontStyle:"italic"});
  99.       inStyle.setStyle(".s_text0",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"normal"});
  100.       inStyle.setStyle(".s_title1",{marginLeft:inMarginTitle,marginRight:inMarginTitle,fontFamily:this.mBaseFont,fontSize:inSize + 2,fontWeight:"bold",fontStyle:"italic"});
  101.       inStyle.setStyle(".s_text1",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"normal"});
  102.       inStyle.setStyle(".s_title2",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize + 1,fontWeight:"bold",fontStyle:"normal"});
  103.       inStyle.setStyle(".s_text2",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"normal"});
  104.       inStyle.setStyle(".s_title3",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"italic"});
  105.       inStyle.setStyle(".s_text3",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"normal"});
  106.       inStyle.setStyle(".s_title4",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"italic"});
  107.       inStyle.setStyle(".s_text4",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"normal"});
  108.       inStyle.setStyle(".s_titoloContributo",{marginLeft:inMarginTitle,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize + 4,fontWeight:"bold",fontStyle:"normal"});
  109.       inStyle.setStyle(".s_didaContributo",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"normal"});
  110.       inStyle.setStyle(".s_didaProspettive",{marginLeft:0,marginRight:0,fontFamily:this.mBaseFont,fontSize:12,fontWeight:"bold",fontStyle:"normal"});
  111.       inStyle.setStyle(".s_titoloThumbPreview",{marginLeft:0,marginRight:0,fontFamily:this.mBaseFont,fontSize:inSize - 2,fontWeight:"normal",fontStyle:"normal"});
  112.       inStyle.setStyle(".alertTitle",{fontFamily:this.mBaseFont,fontSize:14,fontWeight:"bold",fontStyle:"normal",textAlign:"center"});
  113.       inStyle.setStyle(".alertTesto",{fontFamily:this.mBaseFont,fontSize:12,fontWeight:"normal",fontStyle:"normal",textAlign:"center"});
  114.       inStyle.setStyle(".s_Forbici",{fontFamily:"xxForbici",fontWeight:"bold"});
  115.       if(CAppendiceStyleManager.USE_SUB_SUP_FONT == true)
  116.       {
  117.          inStyle.setStyle(".s_Superscript",{marginLeft:0,marginRight:0,fontFamily:this.mApiceFont});
  118.          inStyle.setStyle(".s_Subscript",{marginLeft:0,marginRight:0,fontFamily:this.mPediceFont});
  119.       }
  120.       else
  121.       {
  122.          inStyle.setStyle(".s_Superscript",{marginLeft:0,marginRight:0,fontFamily:this.mBaseFont,fontSize:inSize - 2,fontWeight:"normal",fontStyle:"italic",color:"#FF0000"});
  123.          inStyle.setStyle(".s_Subscript",{marginLeft:0,marginRight:0,fontFamily:this.mBaseFont,fontSize:inSize - 2,fontWeight:"normal",fontStyle:"italic",color:"#0000FF"});
  124.       }
  125.       inStyle.setStyle(".s_Header",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize - 3,fontWeight:"bold",fontStyle:"normal",textAlign:"center"});
  126.       inStyle.setStyle(".s_Footer",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize - 3,fontWeight:"bold",fontStyle:"normal"});
  127.       inStyle.setStyle(".s_Signature",{marginLeft:inMargin,marginRight:inMargin + 5,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"italic",textAlign:"right"});
  128.    }
  129.    function initStyleEmbedded(inStyle, inSize, inMargin, inMarginTitle)
  130.    {
  131.       inStyle.setStyle(".rowText",{fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"bold",fontStyle:"normal"});
  132.       inStyle.setStyle(".menuRowText",{fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"bold",fontStyle:"normal"});
  133.       inStyle.setStyle(".menuRowTextEmbed",{fontFamily:"ArialEmbed",fontSize:11.5,fontWeight:"normal",fontStyle:"normal",textAlign:"center"});
  134.       inStyle.setStyle(".menuProspettive",{fontFamily:"ArialEmbed",fontSize:12,fontWeight:"bold",fontStyle:"normal",textAlign:"left"});
  135.       inStyle.setStyle(".S_SCAPS",{fontSize:this.mNormalSize - 2});
  136.       inStyle.setStyle(".s_content",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"bold",fontStyle:"normal",color:"#444444"});
  137.       inStyle.setStyle(".s_abstract",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"bold",fontStyle:"normal",color:"#444444"});
  138.       inStyle.setStyle(".s_title0",{marginLeft:inMarginTitle,marginRight:inMarginTitle,fontFamily:this.mBaseFont,fontSize:inSize + 4,fontWeight:"bold",fontStyle:"italic"});
  139.       inStyle.setStyle(".s_text0",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"bold",fontStyle:"normal",color:"#444444"});
  140.       inStyle.setStyle(".s_title1",{marginLeft:inMarginTitle,marginRight:inMarginTitle,fontFamily:this.mBaseFont,fontSize:inSize + 3,fontWeight:"bold",fontStyle:"italic"});
  141.       inStyle.setStyle(".s_text1",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"bold",fontStyle:"normal",color:"#444444"});
  142.       inStyle.setStyle(".s_title2",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize + 3,fontWeight:"bold",fontStyle:"italic"});
  143.       inStyle.setStyle(".s_text2",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"bold",fontStyle:"normal",color:"#444444"});
  144.       inStyle.setStyle(".s_title3",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"bold",fontStyle:"italic"});
  145.       inStyle.setStyle(".s_text3",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"bold",fontStyle:"normal",color:"#444444"});
  146.       inStyle.setStyle(".s_title4",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"bold",fontStyle:"italic"});
  147.       inStyle.setStyle(".s_text4",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"bold",fontStyle:"normal",color:"#444444"});
  148.       inStyle.setStyle(".s_titoloContributo",{marginLeft:inMarginTitle,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize + 4,fontWeight:"bold",fontStyle:"normal"});
  149.       inStyle.setStyle(".s_didaContributo",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"bold",fontStyle:"normal"});
  150.       inStyle.setStyle(".s_didaProspettive",{marginLeft:0,marginRight:0,fontFamily:this.mBaseFont,fontSize:12,fontWeight:"bold",fontStyle:"normal"});
  151.       inStyle.setStyle(".s_titoloThumbPreview",{marginLeft:0,marginRight:0,fontFamily:this.mBaseFont,fontSize:inSize - 2,fontWeight:"bold",fontStyle:"normal"});
  152.       inStyle.setStyle(".s_Bold",{color:"#000000"});
  153.       inStyle.setStyle(".alertTitle",{fontFamily:this.mBaseFont,fontSize:14,fontWeight:"bold",fontStyle:"normal",textAlign:"center",color:"#000000"});
  154.       inStyle.setStyle(".alertTesto",{fontFamily:this.mBaseFont,fontSize:12,fontWeight:"bold",fontStyle:"normal",textAlign:"center",color:"#000000"});
  155.       inStyle.setStyle(".s_Forbici",{fontFamily:"xxForbici",fontWeight:"bold",fontStyle:"italic"});
  156.       if(CAppendiceStyleManager.USE_SUB_SUP_FONT == true)
  157.       {
  158.          inStyle.setStyle(".s_Superscript",{marginLeft:0,marginRight:0,fontFamily:this.mApiceFont});
  159.          inStyle.setStyle(".s_Subscript",{marginLeft:0,marginRight:0,fontFamily:this.mPediceFont});
  160.       }
  161.       else
  162.       {
  163.          inStyle.setStyle(".s_Superscript",{marginLeft:0,marginRight:0,fontFamily:this.mBaseFont,fontSize:inSize - 2,fontWeight:"normal",fontStyle:"italic",color:"#FF0000"});
  164.          inStyle.setStyle(".s_Subscript",{marginLeft:0,marginRight:0,fontFamily:this.mBaseFont,fontSize:inSize - 2,fontWeight:"normal",fontStyle:"italic",color:"#0000FF"});
  165.       }
  166.       inStyle.setStyle(".s_Header",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize - 3,fontWeight:"bold",fontStyle:"normal",textAlign:"center"});
  167.       inStyle.setStyle(".s_Footer",{marginLeft:inMargin,marginRight:inMargin,fontFamily:this.mBaseFont,fontSize:inSize - 3,fontWeight:"bold",fontStyle:"normal",textAlign:"left"});
  168.       inStyle.setStyle(".s_Signature",{marginLeft:inMargin,marginRight:inMargin + 5,fontFamily:this.mBaseFont,fontSize:inSize,fontWeight:"normal",fontStyle:"italic",textAlign:"right"});
  169.    }
  170.    function CSStoHTML(my_styleSheet)
  171.    {
  172.       var _loc1_ = "";
  173.       var _loc6_ = my_styleSheet.getStyleNames();
  174.       if(_loc6_.length > 0)
  175.       {
  176.          var _loc5_ = 0;
  177.          while(_loc5_ < _loc6_.length)
  178.          {
  179.             var _loc2_ = _loc6_[_loc5_];
  180.             _loc1_ += "\n" + _loc2_ + "{\n";
  181.             if(!(_loc2_ == ".s_Superscript" or _loc2_ == ".s_Subscript"))
  182.             {
  183.                var _loc3_ = my_styleSheet.getStyle(_loc2_);
  184.                for(var _loc7_ in _loc3_)
  185.                {
  186.                   var _loc4_ = _loc3_[_loc7_];
  187.                   _loc1_ += "\t" + _loc7_ + ": " + _loc4_ + ";\n";
  188.                }
  189.             }
  190.             _loc1_ += "\n}\n";
  191.             _loc5_ = _loc5_ + 1;
  192.          }
  193.       }
  194.       _loc1_ = _loc1_.split("fontFamily").join("font-family");
  195.       _loc1_ = _loc1_.split("fontSize").join("font-size");
  196.       _loc1_ = _loc1_.split("fontStyle").join("font-style");
  197.       _loc1_ = _loc1_.split("fontWeight").join("font-weight");
  198.       _loc1_ = _loc1_.split("letterSpacing").join("letter-spacing");
  199.       _loc1_ = _loc1_.split("marginLeft").join("margin-left");
  200.       _loc1_ = _loc1_.split("marginRight").join("margin-right");
  201.       _loc1_ = _loc1_.split("textAlign").join("text-align");
  202.       _loc1_ = _loc1_.split("textDecoration").join("text-decoration");
  203.       _loc1_ = _loc1_.split("textIndent").join("text-indent");
  204.       return _loc1_;
  205.    }
  206. }
  207.